package com.lnsoft.dqfs.server.handle.codec;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import lombok.Data;

//@Data
public class Frame {

    /**
     * 当前主动下发步骤
     */
    private volatile int process = 0;
    /**
     *  终端是否已完成初始化连接
     */
    private volatile boolean connectFlag = false;

    /**
     *  是否需要反转server端的fcb
     */
    private volatile boolean upServerFcb = false;


    private int readTimeOutNumber = 0;


    /**
     * 数据库对应终端主键ID
     */
    private volatile String clientId;


    private volatile int upgradePackageindex;

    /**
     *  server端Fcb
     */
    private volatile byte serverFcb = 0;

    /**
     *  客户端Fcb
     */
    private volatile byte clientFcb = 0;

    /**
     *  对应的是终端编号(0-65536)
     */
    private int clientName;

    private byte a1;
    private byte a2;

    /**
     *  服务端端口号
     */
    private int serverPort;

    private ByteBuf byteBuf = Unpooled.directBuffer(); // 堆外内存

    private volatile String argId; // 参数表Id

    //  留存主站主发完的报文，用于重发
    private byte[] sendingFrame = null;

    //  终端上传数据是否完成的标志
    private boolean finished = false;

    //  升级之前终端的版本号
    private String oldVersion = null;

    //  数据库中对应的升级记录ID,便于更新记录信息
    private String recordId = null;

	public int getProcess() {
		return process;
	}

	public void setProcess(int process) {
		this.process = process;
	}

	public boolean isConnectFlag() {
		return connectFlag;
	}

	public void setConnectFlag(boolean connectFlag) {
		this.connectFlag = connectFlag;
	}

	public boolean isUpServerFcb() {
		return upServerFcb;
	}

	public void setUpServerFcb(boolean upServerFcb) {
		this.upServerFcb = upServerFcb;
	}

	public int getReadTimeOutNumber() {
		return readTimeOutNumber;
	}

	public void setReadTimeOutNumber(int readTimeOutNumber) {
		this.readTimeOutNumber = readTimeOutNumber;
	}

	public String getClientId() {
		return clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	public int getUpgradePackageindex() {
		return upgradePackageindex;
	}

	public void setUpgradePackageindex(int upgradePackageindex) {
		this.upgradePackageindex = upgradePackageindex;
	}

	public byte getServerFcb() {
		return serverFcb;
	}

	public void setServerFcb(byte serverFcb) {
		this.serverFcb = serverFcb;
	}

	public byte getClientFcb() {
		return clientFcb;
	}

	public void setClientFcb(byte clientFcb) {
		this.clientFcb = clientFcb;
	}

	public int getClientName() {
		return clientName;
	}

	public void setClientName(int clientName) {
		this.clientName = clientName;
	}

	public byte getA1() {
		return a1;
	}

	public void setA1(byte a1) {
		this.a1 = a1;
	}

	public byte getA2() {
		return a2;
	}

	public void setA2(byte a2) {
		this.a2 = a2;
	}

	public int getServerPort() {
		return serverPort;
	}

	public void setServerPort(int serverPort) {
		this.serverPort = serverPort;
	}

	public ByteBuf getByteBuf() {
		return byteBuf;
	}

	public void setByteBuf(ByteBuf byteBuf) {
		this.byteBuf = byteBuf;
	}

	public String getArgId() {
		return argId;
	}

	public void setArgId(String argId) {
		this.argId = argId;
	}

	public byte[] getSendingFrame() {
		return sendingFrame;
	}

	public void setSendingFrame(byte[] sendingFrame) {
		this.sendingFrame = sendingFrame;
	}

	public boolean isFinished() {
		return finished;
	}

	public void setFinished(boolean finished) {
		this.finished = finished;
	}

	public String getOldVersion() {
		return oldVersion;
	}

	public void setOldVersion(String oldVersion) {
		this.oldVersion = oldVersion;
	}

	public String getRecordId() {
		return recordId;
	}

	public void setRecordId(String recordId) {
		this.recordId = recordId;
	}

}
